# -*- coding: utf-8 -*-
from flask import render_template

from ammunition.article import bp
from ammunition.note.documents import Note, Book


@bp.route("/<string:oid>")
def detail_view(oid=None):
    note = Note.find_by_oid(oid)
    book = Book.find_by_oid(note.book_id)
    return render_template('article/detail.html', book=book, article=note)


@bp.route("/b-<string:oid>")
def book_view(oid=None):
    book = Book.find_by_oid(oid)
    articles = book.notes
    return render_template('article/book.html', book=book, articles=articles)
